package antLogic;

/**
 * Created by IntelliJ IDEA.
 * User: home
 * Date: Jul 11, 2007
 * Time: 11:24:04 PM
 * To change this template use File | Settings | File Templates.
 */
public class Locomotion {

    Ant host;
    Path currentPath;

    public Locomotion(Ant host) {
        this.host = host;        
    }

    protected void turnAndWalkForever(int turnAmount)  {
        currentPath = new StraightPath(host);
        host.getBearing().add(turnAmount);
        AntManager.antMgr.log(this,"Ant #" + host.getAntId() + " has turned " + turnAmount + " degrees (" + host.getBearing().getValue());
        if(!AntManager.world.updateAntPath(host.getAntId())) {
            AntManager.antMgr.logWarn(this,"Could not update path to " + currentPath.getName() + " for ant #" + host.getAntId());
        }

    }

    protected void halt()  {
        currentPath = null;
        AntManager.world.updateAntPath(host.getAntId());
    }

    protected void walkInSearchPattern()  {
        currentPath = new SearchPath(host);
        if(!AntManager.world.updateAntPath(host.getAntId())) {
            AntManager.antMgr.logWarn(this,"Could not update path to " + currentPath.getName() + " for ant #" + host.getAntId());
        }
    }
}
